// app.js
const utils=require('./utils/util')
const app = getApp();
App({
  globalData: {
    imgUrl:'http://demo.gzhslhr.cn/',
    apiUrl:'https://demo.gzhslhr.cn/api.php/',
    userInfo: null,
    option01:[],//综合实力的数组
    option02:[],//职位分析
    isGrant:'',//是否授权 
    userID:'',//用户id
    isBind:'',
  },
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录并且获取用户openid
    wx.login({
    //获取code
    success: function (res) {
      console.log(res);
      var code = res.code; //返回code
      var appId = 'wx15b92f26c12153b8';
      var secret = '0ed9b41d67c8f2d484a17196338919c0';
      wx.request({
        url: 'https://api.weixin.qq.com/sns/jscode2session?appid=' + appId + '&secret=' + secret + '&js_code=' + code + '&grant_type=authorization_code',
        data: {},
        header: {
          'content-type': 'json'
        },
        success: function (res) {
          console.log(res);
          var openid = res.data.openid //返回openid
          wx.setStorageSync('session_key', res.data.session_key);
          wx.setStorageSync('openid', openid);//存在本地
        }
      })
    }
    })

  },
  onShow (options) {
  },
  onHide () {
  },

})
